<?php
require_once("../inc/bootstrap.php");

/* Report a hit (file info page view) or file download
   Parameters: a=d(ownload)|v(iew), id=post ID
*/

	if ($serverName == $SQLMaster && !empty($_GET['id']) && !empty($_GET['a']))
	{
		$ID = intval($_GET['id']);
		$mysqli = dbconnect();
		if ($_GET['a'] == 'd')
		{
			$query = "UPDATE uploads SET Downloads=Downloads+1 WHERE ID=?";
			$statement = $mysqli->stmt_init();
			$statement->prepare($query);
			$statement->bind_param("i", $ID);
			$statement->execute();
			$statement->close();
			$mysqli->close();
		}
		elseif ($_GET['a'] == 'v')
		{
			$query = "UPDATE uploads SET Pageviews=Pageviews+1 WHERE ID=?";
			$statement = $mysqli->stmt_init();
			$statement->prepare($query);
			$statement->bind_param("i", $ID);
			$statement->execute();
			$statement->close();
			$mysqli->close();
		}
	}

?>